$(function () {
    $("#div1").hide()
    $("#cpscgxsjdcx").bootstrapTable({
        method:"post",
        contentType:'application/json',
        url:"/DFile/cpgxsjdcx",
        striped:true,
        pageNumber:1,
        pagination:true,
        sidePagination:'server',
        pageSize:3,
        pageList:[2,3,5,6],
        queryParams:function (parmes) {
            return{
                pageNum:(parmes.offset / parmes.limit) + 1,
                pageSize:parmes.limit,
                registerTime:$("#registerTime").val(),
                checker:$("#checked").val(),
            }
        },
        columns:[
            {title:"设计单编号",field:"designId",align:'center'},
            {title:"产品编号",field:"productId",align:'center'},
            {title:"产品名称",field:"productName",align:'center'},
            {title:"登记时间",field:"registerTime",align:'center'},
            {title:"设计单状态",field:"checkTag",align:'center',
                formatter:function (value,row,index) {
                    if (value == 0){
                        return "等待"
                    }
                    if (value == 1){
                        return "完成"
                    }
                    if (value == 2){
                        return "等待"
                    }
                }
            },
            {title:"审核状态",field:"checkTag",align:'center',
                 formatter:function (value,row,index) {
                     if (value == 0){
                         return "<font color=\"orange\">等待</font>"
                     }
                     if (value == 1){
                         return "<font color=\"green\">通过</font>"
                     }
                     if (value == 2){
                         return "<font color=\"red\">未通过</font>"
                     }
                 }
                },
            {title:"查看",field:"designId",align:'center',
                formatter:function (value,row,index) {
                    let a="<button onclick='ck("+row.id+")'class=\"btn btn-primary\" >查看</button>"
                    return a;
                }
            }
        ]
    })
})

function ck(a) {
    $("#cpsygxall").hide()
    $("#div1").show()
    $.ajax({
        type:"post",
        contentType:"application/json;charset:utf-8",
        url:"/DFile/ckks/"+a,
        dataType:"json",
        async:true,
        success:function (data) {
            $("#name").html(data.productName)
            $("#bh").html(data.productId)
            $("#designer").html(data.designer)
            $("#register").html(data.register)
            $("[name=registerTime]").html(data.registerTime)
            $("#comment").html(data.procedureDescribe)
            $("#sh").html(data.checker)
            $("#shtime").html(data.checkTime)

            $.ajax({
                type:"post",
                contentType:"application/json;charset:utf-8",
                url:"/DFile/ckk/"+a,
                dataType:"json",
                async:true,
                success:function (data) {
                        let tab=document.getElementById("gxtab")
                        tab.innerHTML="";
                        for (i=0;i<data.length;i++){
                            tab.innerHTML+="<tr><td>"+data[i].procedureName+"</td><td>"+data[i].procedureId+"</td><td>"+data[i].procedureDescribe+"</td>" +
                                "<td>"+data[i].labourHourAmount+"</td><td>"+data[i].amountUnit+"</td><td>"+data[i].costPrice+"</td><td>"+data[i].subtotal+"</td></tr>"
                        }
                }
                })
        }
    })
}

function kscx() {
    $("#cpscgxsjdcx").bootstrapTable("refresh")
}

function fhu() {
    $("#cpsygxall").show()
    $("#div1").hide()
}